cmake_minimum_required(VERSION 3.18)
project(industrial_robot_control VERSION 2.0.0 LANGUAGES CXX)

# C++标准配置
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# 编译选项
set(CMAKE_BUILD_TYPE Release)
add_compile_options(
    -Wall -Wextra -Wpedantic 
    -O2 
    -march=native
    -Wl,--no-as-needed
    -pthread
)

# 查找依赖
find_package(PkgConfig REQUIRED)
pkg_check_modules(ETHERCAT libethercat REQUIRED)
pkg_check_modules(MODBUS libmodbus REQUIRED)
pkg_check_modules(YAML_CPP yaml-cpp REQUIRED)
pkg_check_modules(WEBSOCKETS libwebsockets REQUIRED)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
find_package(Threads REQUIRED)
find_package(fmt REQUIRED)

# 包含子目录
add_subdirectory(src)

# 安装配置
install(DIRECTORY config/ DESTINATION /etc/robot_control)
install(FILES scripts/systemd/industrial-robot-control.service DESTINATION /etc/systemd/system)
